package com.github.thinwonton.springboot.showcase.jta.orders.service;

import com.github.thinwonton.springboot.showcase.jta.orders.constant.OrderConstants;
import com.github.thinwonton.springboot.showcase.jta.orders.dao.OrdersDao;
import com.github.thinwonton.springboot.showcase.jta.orders.domain.Orders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * OrdersService
 *
 * @author hugo
 * @date 2018/8/22
 */
@Service
public class OrdersService {

    @Autowired
    private OrdersDao ordersDao;

    @Transactional(rollbackFor = Exception.class)
    public void createOrder() {
        Orders record = new Orders();
        record.setStatus(OrderConstants.ORDER_STATUS_PAID);
        ordersDao.insert(record);

        int o = 1 / 0;
    }

}
